/* PCAS (Province City Area Selector 省、市、地区联动选择JS封装类) Ver 2.01 完整版 *\

　制作时间:2005-12-30
　更新时间:2006-01-24
　数据修正:2006-08-17
　文档大小:18KB
　演示地址:http://www.popub.net/script/pcasunzip.html
　下载地址:http://www.popub.net/script/pcasunzip.js
　应用说明:页面包含<script type="text/javascript" src="pcasunzip.js"></script>
	省市联动
		new PCAS("Province","City")
		new PCAS("Province","City","吉林省")
		new PCAS("Province","City","吉林省","吉林市")
	省市地区联动
		new PCAS("Province","City","Area")
		new PCAS("Province","City","Area","吉林省")
		new PCAS("Province","City","Area","吉林省","松原市")
		new PCAS("Province","City","Area","吉林省","松原市","宁江区")
	省、市、地区对象取得的值均为实际值。
	注：省、市、地区提示信息选项的值为""(空字符串)

　感谢
　　　网友418528#gmail.com对数据进行的核实工作 2006-08-07

\*** 程序制作/版权所有:崔永祥(333) E-Mail:zhadan007@21cn.com 网址:http://www.popub.net ***/

SPT = "请选择省份";
SCT = "请选择城市";
SAT = "请选择地区";
ShowT = 1; //提示文字 0:不显示 1:显示
PCAD="内蒙古自治区:150000$"+
"内蒙古自治区:150000,内蒙古自治区:000000,省级:150000|"+
"呼和浩特市:150100,呼和浩特市:150100,新城区:150102,回民区:150103,玉泉区:150104,赛罕区:150105,土默特左旗:150121,托克托县:150122,和林格尔县:150123,清水河县:150124,武川县:150125|"+
"包头市:150200,包头市:150200,东河区:150202,昆都仑区:150203,青山区:150204,石拐区:150205,白云鄂博矿区:150206,九原区:150207,土默特右旗:150221,固阳县:150222,达尔罕茂明安联合旗:150223|"+
"乌海市:150300,乌海市:150300,海勃湾区:150302,海南区:150303,乌达区:150304|"+
"赤峰市:150400,赤峰市:150400,红山区:150402,元宝山区:150403,松山区:150404,阿鲁科尔沁旗:150421,巴林左旗:150422,巴林右旗:150423,林西县:150424,克什克腾旗:150425,翁牛特旗:150426,喀喇沁旗:150428,宁城县:150429,敖汉旗:150430|"+
"通辽市:150500,通辽市:150500,科尔沁区:150502,科尔沁左翼中旗:150521,科尔沁左翼后旗:150522,开鲁县:150523,库伦旗:150524,奈曼旗:150525,扎鲁特旗:150526,霍林郭勒市:150581|"+
"鄂尔多斯市:150600,鄂尔多斯市:150600,东胜区:150602,达拉特旗:150621,准格尔旗:150622,鄂托克前旗:150623,鄂托克旗:150624,杭锦旗:150625,乌审旗:150626,伊金霍洛旗:150627|"+
"呼伦贝尔市:150700,呼伦贝尔市:150700,海拉尔区:150702,阿荣旗:150721,莫力达瓦达斡尔族自治旗:150722,鄂伦春自治旗:150723,鄂温克族自治旗:150724,陈巴尔虎旗:150725,新巴尔虎左旗:150726,新巴尔虎右旗:150727,满洲里市:150781,牙克石市:150782,扎兰屯市:150783,额尔古纳市:150784,根河市:150785|"+
"巴彦淖尔市:150800,巴彦淖尔市:150800,临河区:150802,五原县:150821,磴口县:150822,乌拉特前旗:150823,乌拉特中旗:150824,乌拉特后旗:150825,杭锦后旗:150826|"+
"乌兰察布市:150900,乌兰察布市:150900,集宁区:150902,卓资县:150921,化德县:150922,商都县:150923,兴和县:150924,凉城县:150925,察哈尔右翼前旗:150926,察哈尔右翼中旗:150927,察哈尔右翼后旗:150928,四子王旗:150929,丰镇市:150981|"+
"兴安盟:152200,兴安盟:152200,乌兰浩特市:152201,阿尔山市:152202,科尔沁右翼前旗:152221,科尔沁右翼中旗:152222,扎赉特旗:152223,突泉县:152224|"+
"锡林郭勒盟:152500,锡林郭勒盟:152500,二连浩特市:152501,锡林浩特市:152502,阿巴嘎旗:152522,苏尼特左旗:152523,苏尼特右旗:152524,东乌珠穆沁旗:152525,西乌珠穆沁旗:152526,太仆寺旗:152527,镶黄旗:152528,正镶白旗:152529,正蓝旗:152530,多伦县:152531|"+
"阿拉善盟:152900,阿拉善盟:152900,阿拉善左旗:152921,阿拉善右旗:152922,额济纳旗:152923";
if (ShowT) PCAD = SPT + "$" + SCT + "," + SAT + "#" + PCAD;
PCAArea = [];
PCAP = [];
PCAC = [];
PCAA = [];
PCAN = PCAD.split("#");
for (i = 0; i < PCAN.length; i++) {
    PCAA[i] = [];
    TArea = PCAN[i].split("$")[1].split("|");
    for (j = 0; j < TArea.length; j++) {
        PCAA[i][j] = TArea[j].split(",");
        if (PCAA[i][j].length == 1) PCAA[i][j][1] = SAT;
        TArea[j] = TArea[j].split(",")[0]
    }
    PCAArea[i] = PCAN[i].split("$")[0] + "," + TArea.join(",");
    PCAP[i] = PCAArea[i].split(",")[0];
    PCAC[i] = PCAArea[i].split(',')
}
function PCAS() {
    this.SelP = document.getElementsByName(arguments[0])[0];
    this.SelC = document.getElementsByName(arguments[1])[0];
    this.SelA = document.getElementsByName(arguments[2])[0];
    this.DefP = this.SelA ? arguments[3] : arguments[2];
    this.DefC = this.SelA ? arguments[4] : arguments[3];
    this.DefA = this.SelA ? arguments[5] : arguments[4];
    this.SelP.PCA = this;
    this.SelC.PCA = this;
    this.SelP.onchange = function() {
        PCAS.SetC(this.PCA)
    };
    if (this.SelA) this.SelC.onchange = function() {
        PCAS.SetA(this.PCA)
    };
    PCAS.SetP(this)
};
PCAS.SetP = function(PCA) {
    for (i = 0; i < PCAP.length; i++) {
        PCAPT = PCAP[i].split(":")[0];
        PCAPV = PCAP[i].split(":")[1];
        if (PCAPT == SPT) PCAPV = "";
        PCA.SelP.options.add(new Option(PCAPT, PCAPV));
        if (PCA.DefP == PCAPV) PCA.SelP[i].selected = true
    }
    PCAS.SetC(PCA)
};
PCAS.SetC = function(PCA) {
    PI = PCA.SelP.selectedIndex;
    PCA.SelC.length = 0;
    for (i = 1; i < PCAC[PI].length; i++) {
        PCACT = PCAC[PI][i].split(":")[0];
        PCACV = PCAC[PI][i].split(":")[1];
        if (PCACT == SCT) PCACV = "";
        PCA.SelC.options.add(new Option(PCACT, PCACV));
        if (PCA.DefC == PCACV) PCA.SelC[i - 1].selected = true
    }
    if (PCA.SelA) PCAS.SetA(PCA)
};
PCAS.SetA = function(PCA) {
    PI = PCA.SelP.selectedIndex;
    CI = PCA.SelC.selectedIndex;
    PCA.SelA.length = 0;
    for (i = 1; i < PCAA[PI][CI].length; i++) {
        PCAAT = PCAA[PI][CI][i].split(":")[0];
        PCAAV = PCAA[PI][CI][i].split(":")[1];
        if (PCAAT == SAT) PCAAV = "";
        PCA.SelA.options.add(new Option(PCAAT, PCAAV));
        if (PCA.DefA == PCAAV) PCA.SelA[i - 1].selected = true
    }
}